/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __F62FB793_81B9_42d1_AC46_38C45FF2585A__
#define __F62FB793_81B9_42d1_AC46_38C45FF2585A__


/////////////////////////////////////////////////////////////////////////////////////////
// 

namespace xos_box
{
    // 
    // buf interface
    // 
    class i_buf : public xos::i_release
    {
    public:
        enum enumBufSize
        {
            BUF_SIZE = 32 * 1024
        };

    protected:
        virtual ~i_buf(){}

    public:
        // 
        // char * : char * data before get.
        //    int : get data len
        // 
        virtual char * get_data( char * lpszData, int nWant, int * lpnGetLen, int * lpnLenNeeded ) = 0;
        virtual int get_data( xos_box::i_big_buf * pBuf, int nWant, int * lpnGetLen ) = 0;
        virtual int get_data( xos_box::i_buf * pBuf, int nWant, int * lpnGetLen ) = 0;

        virtual int set_end_zero() = 0;
        virtual int reset() = 0;

        // 
        // ret : add data len
        // 
        virtual int add_data( const char * lpszData, int nWant, bool bTail ) = 0;
        virtual int add_str( const char * lpszData, bool bTail ) = 0;
        virtual int add_data( xos_box::i_big_buf * pBuf, bool bTail ) = 0;
        virtual int add_data( xos_box::i_buf * pBuf, bool bTail ) = 0;

		virtual int move_data_to_begin() = 0;
        virtual int move_data_to_end() = 0;

        virtual int get_len( int * lpnDataLen ) = 0;
        virtual int set_len( int nLen ) = 0;

        virtual int get_pos( int * lpnPos ) = 0;
        virtual int set_pos( int nPos ) = 0;

        virtual int get_buf_size( int * lpnBufLen ) = 0;

        // 
        // only in i_buf
        // 
        virtual WSABUF * get_wsa_buf( WSABUF ** lppWsaBuf ) = 0;
    };
}

#endif // __F62FB793_81B9_42d1_AC46_38C45FF2585A__
